package com.smile.stream.stream;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.stream.Stream;

/**
 * @author LiYuhang
 * @version 0.1
 * @application 生成stream
 * @Date 2021/10/7 14:56
 */
public class GenerateStreamDemo {
    public static void main(String[] args) {
        Stream<Integer> stream1 = Stream.of(1,2,3);
        stream1.forEach(System.out::println);
        System.out.println("stream1 = ");

        Stream<Object> build = Stream
                .builder()
                .add(4)
                .add(5)
                .build();
        System.out.println("build = ");
        build.forEach(System.out::println);



        Stream<Object> concat1 = Stream.concat( Stream.of(1,2,3),Stream.builder().add(4).add(5).build());
        System.out.println("concat = ");
        concat1.forEach(System.out::println);
       // Stream<Object> concat2 = Stream.concat(stream1,build);
        // concat2.forEach(System.out::println);

        ArrayList<Object> arrayList = new ArrayList<>();
        arrayList.add(7);
        arrayList.add(8);
        arrayList.add(9);
        Stream<Object> stream = arrayList.stream();

        Stream<Object> stream2 = new HashMap<>().values().stream();
        Stream<Object> stream3 = new HashSet<>().stream();


        System.out.println("stream = ");
        stream.forEach(System.out::println);
        Stream<Integer> limit = Stream.iterate(0,n -> n + 1).limit(5);
        System.out.println("limit = " );
        limit.forEach(System.out::println);

    }
}
